<%-- 
    Document   : imoveis
    Created on : Sep 22, 2013, 8:53:53 PM
    Author     : Fabio
--%>

<%@page import="model.Usuario"%>
<%@page import="java.util.Map"%>
<%@page import="model.Imovel"%>
<%@page import="java.util.HashMap"%>
<%@page import="model.BD_Sistema"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Meus imoveis</title>
    </head>
    <body>
    <center>
        <h1>Meus imoveis</h1>
        <table>
            <tr>
                <td width="200px"><a href="imoveis_cadastro.jsp">Novo imovel</a></td>
                <td><a href="home.jsp" width="200px">Voltar</a></td>
            </tr>
        </table>
        <%  BD_Sistema bds = BD_Sistema.getInstance();

            bds.setBd_imovel((HashMap) session.getAttribute("imoveis"));
            Usuario u = bds.buscaUsuario((String) session.getAttribute("sessao_atual"));

            Imovel i = new Imovel();
            if (bds.getBd_imovel() != null) {
                for (Integer prop : u.getPropriedades()) {
                    i = bds.buscaImovel(prop);
        %>
        <table>
            <tr>
                <td>Id:</td>
                <td><% out.print(i.getId_imovel());%></td>
            </tr>
            <tr>
                <td>Categoria:</td>
                <td><% out.print(i.getCategoria());%></td>
            </tr>
            <tr>
                <td>Tipo:</td>

                <td><% out.print(i.getTipo());%></td>
            </tr>
            <tr>
                <td>Endereco:</td>
                <td><% out.print(i.getLogradouro());%></td>
            </tr>
            <tr>
                <td>Numero de quartos:</td>

                <td><% out.print(i.getNroQuartos());%> </td>
            </tr>
            <tr>
                <td>Valor:</td>
                <td><% out.print(i.getValor());%></td>
            </tr>
            <tr>
                <td colspan="2">
                    <form action="imoveis_cadastro.jsp">
                        <input type="hidden" name="id_im" value=<%= i.getId_imovel()%>>
                        <input type="submit" value="Editar informaçoes">
                    </form>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <hr>
            </tr>
        </table>

        <%
                }
            }
        %>
    </center>
</body>
</html>

